﻿@model RepositoryCommitModel
@using System.Globalization
@using Bonobo.Git.Server.Extensions
<div class="commit pure-g">
    <div class="pure-u-3-5">
        <h2>
            <a class="commit-url" href="@Url.Action("Commit", new { id = ViewBag.ID, commit = Model.ID })">@Model.Message</a>
            @if (!string.IsNullOrEmpty(Model.MessageShort))
            {
                <a class="more-commit-info-toggler" onclick="$('#more@(Model.ID)').toggle();">&hellip;</a>
            }
        </h2>

        <div class="commitdate">
            @Model.Date.ToString()
        </div>
        @if (Model.Links.Count() > 0)
        {
        <span class="links">

            @foreach (var link in Model.Links)
            {
                <a target="_blank" class="linkified" href="@link">@link</a>
            }
        </span>
        }
        <span class="tag">
            @foreach (var stag in Model.Tags)
            {
                @Html.ActionLink(stag, "Commits", new { id = ViewBag.ID, encodedName = stag, encodedPath = String.Empty })
            }
        </span>
        @if (!string.IsNullOrEmpty(Model.MessageShort))
        {
            <pre style="display:none;" id="more@(Model.ID)">@Model.MessageShort</pre>
        }

        <div class="notes">
            @foreach (var note in Model.Notes)
            {
                <p>
                    *@note.Namespace* @note.Message
                </p>
            }
        </div>
    </div>
    <div class="pure-u-2-5 metadata">
        @if (UserConfiguration.Current.IsCommitAuthorAvatarVisible)
        {
            <div>
                <img src="@Model.AuthorAvatar" alt="@Model.Author" class="avatar" />
            </div>
        }
        <div>
            <h4>@Model.Author</h4>
            <p>@Model.GetType().GetDisplayValue("ID"): @Html.ActionLink(Model.ID.Substring(0, 7), "Commit", new { id = ViewBag.ID, commit = Model.ID })</p>
            <p>@Model.GetType().GetDisplayValue("TreeID"): @Html.ActionLink(Model.TreeID.Substring(0, 7), "Tree", new { id = ViewBag.ID, encodedName = PathEncoder.Encode(Model.ID) })</p>
            @if (Model.Parents != null && Model.Parents.Count() > 0)
            {
                <p>
                    @Model.GetType().GetDisplayValue("Parents"):
                    @foreach (var parent in Model.Parents)
                    {
                        @Html.ActionLink(parent.Substring(0, 7), "Commit", new { id = ViewBag.ID, commit = parent })<br />
                    }
                </p>
            }
        </div>
    </div>
</div>
